from starlette.config import Config
import os.path


if os.path.exists('./config.env.local'):
    _config = Config("config.env.local")
else:
    _config = Config("config.env")

DEBUG = _config("DEBUG", cast=bool, default=False)
DATABASE_URL = _config("DATABASE_URL")
CONNECTION_POOL_SIZE = _config("DATABASE_CONNECTION_POOL_SIZE", cast=int)

REDIS_HOST = _config("REDIS_HOST", default="127.0.0.1")
REDIS_PORT = _config("REDIS_PORT", cast=int, default=6379)
REDIS_PASSWORD = _config("REDIS_PW", default="")
REDIS_DB = _config("REDIS_DB", cast=int, default=0)

ENT_CORP_ID = _config("CORP_ID")
ENT_APP_AGENT = _config("CORP_APP_AGENT")
ENT_APP_SECRET = _config("CORP_SECRET")
ENT_APP_TOKEN = _config("CORP_TOKEN")
ENT_APP_ENCRYPT_KEY = _config("CORP_ENCKEY", default="")
ENT_ACCESS_TOKEN = _config("CORP_ACCESS_TOKEN")
ENT_JS_API_TOKEN = _config("CORP_JS_API_TOKEN")

PUB_APP_ID = _config("PUBLIC_ID")
PUB_APP_SECRET = _config("PUBLIC_SECRET")
PUB_APP_TOKEN = _config("PUBLIC_TOKEN")
PUB_APP_ENCRYPT_KEY = _config("PUBLIC_ENCKEY", default="")
PUB_ACCESS_TOKEN = _config("PUBLIC_ACCESS_TOKEN")
PUB_JS_API_TOKEN = _config("PUBLIC_JS_API_TOKEN")
PUB_WEB_TOKEN = _config("PUBLIC_WEB_TOKEN")
PUB_WEB_REFRESH_TOKEN = _config("PUBLIC_WEB_REFRESH_TOKEN")

TOKEN_SECRET = _config("TOKEN_SECRET")
TOKEN_VALID_DURATION = _config("TOKEN_VALID_DURATION", cast=int)

UPLOAD_PATH = _config("UPLOAD_PATH")
LOG_PATH = _config("LOG_PATH")


TEMPLATE_PERIOD_REPORT = _config("TEMPLATE_PERIOD_REPORT")
TEMPLATE_AUTHORIZE = _config("TEMPLATE_AUTHORIZE_NOTIFY")
TEMPLATE_URGE = _config("TEMPLATE_URGE_NOTIFY")
